Skip to content

The pull request sync reads every repository and keeps pages GitHub answers in part - #993

Open
nambok wants to merge 4 commits into
mainfrom
prs-first-read
Open

nambok wants to merge 4 commits into
mainfrom
prs-first-read

Conversation

@nambok

@nambok nambok commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

The pull requests view could stay empty for two reasons. A field the installation may not read made GitHub answer the sync's search in part, and the sync threw the whole page away. The sync also read only repositories enabled for CoderHelm's work, and repository rows are stored not enabled. This keeps partial answers, reads every repository the installation can see, and asks for a team's first read as soon as the page is opened.

Changes

  • worker/src/clients/github.rs: graphql_read_partial returns the data with its errors; only an answer with no data fails.
  • common/src/pr_record.rs:
    • split_graphql and strip_refused: each field GitHub refused (FORBIDDEN, per node) is taken out of its node, so the record keeps what webhooks stored. Conversations refused read as unknown, never as none open.
    • search_query(omit): following pages leave the refused fields out, and a page whose nodes were nulled by one is read again without it.
    • FirstRead (PRFIRST), its due rule and a conditional claim, one ask per ten minutes.
  • worker/src/passes/pr_records.rs:
    • Reads every repository row of the team, with no enabled filter and nothing filtered by author or label. The history backfill uses the same partial reads.
    • Records the first read's progress per organization.
    • Logs one INFO line per team ("Pull request sync: team read") with the repositories, pull requests written, completeness and fields unavailable.
  • gateway/src/routes/prs.rs, prs_overview.rs: return first_read {reading, repos_read, repos_total, done}. When the team's first read never finished and no ask is in flight, they ask the worker for it (PrRecordsSync), under the shared sweep:dashboard_prs budget.
  • Docs: docs/pull-requests.md, docs/pull-requests/api_contract.md.

Verification

  • cargo fmt --check, cargo clippy -p common -p worker -p gateway --all-targets -- -D warnings: clean.
  • cargo test -p common -p worker -p gateway: all passed, apart from one new test whose expectation was then corrected. That test was re-run with the rest of the pr_record tests (19 passed).
  • New tests:
    • A page with GitHub's exact FORBIDDEN error per node keeps every pull request, and the refused field keeps its stored value and reads as unknown.
    • An answer with no data is still an error.
    • The next pages' query leaves refused fields out and stays read-only and balanced.
    • The first read is asked until it finishes and never twice at once.
    • First-read progress counts repositories per organization.

…nswers in part

A field the installation's permissions don't cover comes back null with a
FORBIDDEN error per node; the sync threw the whole page away and paused the
backfill. It now keeps the data beside the errors: refused fields leave the
node, so the record keeps what webhooks stored and conversations read as
unknown, and the following pages leave them out of the query (a page whose
nodes were nulled is read again without them).

The sync read only repositories enabled for CoderHelm's work, and repository
rows are stored not enabled, so a team with none enabled was never read. It
now reads every repository the installation can see.

The pull requests page and the overview ask for the team's first read when
it never finished (installs from before the view never send an install
event), claimed so one ask goes out per ten minutes, and return its
progress as first_read (repositories read of all). One INFO line per team
says the repositories read, pull requests written and fields unavailable.
Two open conversations already stored still hold the merge; none known reads
as unknown.
@nambok nambok added the ch-review CoderHelm reviews this pull request label Dec 6, 2026
coderhelm[bot]

This comment was marked as outdated.

… nothing to read ends

A page with a pull request GitHub returned as null, or an error that names
no single refused field, no longer counts the listing complete: those pull
requests are read from the REST list of each repository's open pull
requests, and records are removed only when the listing is whole. The
history backfill pauses on such a page instead of passing the window over.

A team with no repositories stored, or whose GitHub can't be reached, ends
its first read with the reason, so the page says it rather than reading and
asking again every ten minutes.
coderhelm[bot]

This comment was marked as outdated.

@coderhelm
coderhelm Bot dismissed their stale review December 6, 2026 06:54

Superseded by CoderHelm's latest review

@coderhelm

coderhelm Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Auto-merge · waiting

  • ✅ CoderHelm approved
  • ⏳ CI running: Analyze (rust)
    Commit into main. Merges on its own once every item is done.
    Stop auto-merge or comment @coderhelm stop auto-merge.

@coderhelm coderhelm Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with notes on da3e5b1: the PR's own change is unchanged since 142735e; the new commits only bring in main. CoderHelm's full review of 142735e holds for this commit, so it was not reviewed again.


Was this review right? Rate it 👍 / 👎 so the reviewer learns · reply @coderhelm re-review or @coderhelm <question>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant